-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSONMarshal to go sdk #11609
Add JSONMarshal to go sdk #11609
Conversation
Changelog[uncommitted] (2022-12-09)Features
|
Can you provide an example here? I have other issues with the |
Yup firstly how would you make Secondly how would you make that work if one of the nested secrets was unknown? The overall json parse should then be unknown. Likewise for secrets. |
76beddd
to
c34b3d4
Compare
This is not as useful for Go as it is for other languages, but it's consistent and it saves an Apply call. Ideally we would handle nested Output types during marshalling, but to do that correctly we need some way to get access to per-call-to-JSONMarshal flags to note if we see any unknowns, or secrets. Go just (AFAIK) have any way to support doing that. So we do the next best thing which is we at least error that nested Outputs can't be marshalled. Note that the `Output` interface doesn't embed the `Marshal` interface because there _may_ be users who have wrote their own `Output` types and that would be a breaking change.
c34b3d4
to
9ca4627
Compare
Taking another look, I think this would require leaving encoding/json framework. 😒 You would need to manually marshal into
If the value is secret, I would mark the whole thing as secret. If its unknown, I would abort, and mark the returned value as unknown. |
Yup that's what this method does in dotnet and python. The fun is how you track that in Go where you don't have any async context to grab inside the marshal methods. I think your right we could do better here if we didn't use encoding/json. That might be worth doing. |
We could replicate the encoding/json interface, observing json tags and |
bors merge |
Build succeeded: |
Description
This is not as useful for Go as it is for other languages, but it's consistent and it saves an Apply call.
Ideally we would handle nested Output types during marshalling, but to do that correctly we need some way to get access to per-call-to-JSONMarshal flags to note if we see any unknowns, or secrets.
Go just doesn't (AFAIK) have any way to support doing that.
So we do the next best thing which is we at least error that nested Outputs can't be marshalled. Note that the
Output
interface doesn't embed theMarshal
interface because there may be users who have wrote their ownOutput
types and that would be a breaking change.Checklist
make changelog
and committed thechangelog/pending/<file>
documenting my change